package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.result.PageResult;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface DishMapper {


    /**
     * 分页查询
     * @param dishPageQueryDTO
     * @return
     */
    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 新增菜品和对应的口味数据
     * @param dish
     */
    @AutoFill(OperationType.INSERT)
    void save(Dish dish);

    /**
     * 菜品批量删除
     * @param ids
     */
    void delete(Long[] ids);

    /**
     * 菜品起售停售
     * @param status
     * @param id
     */
    void startOrStop(Integer status, Long id);

    /**
     * 修改菜品
     * @param dish
     */
    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    DishDTO getByIdWithFlavor(Long id);

    /**
     * 根据id查询菜品
     * @param id
     * @return
     */
    Dish getById(Long id);

    /**
     * 根据分类id查询菜品
     * @param categoryId
     * @return
     */
    DishDTO[] getByCategoryId(Long categoryId);

    /**
     * 根据分类id查询菜品
     * @param dish
     * @return
     */
    DishDTO[] getByCategoryId(Dish dish);

    DishDTO[] getByCategoryIdWithStatus(Dish dish);

    @Select("SELECT name FROM dish WHERE id =#{dishId} and status = #{status}")
    String getByIdStatus(Long dishId, Integer status);

    Integer getSetmealsStatus(Integer disable);
}
